package com.own.business.exam.business.util;

import com.own.business.exam.entity.vo.ExamVo;
import com.own.business.question.entity.po.Practice;
import com.own.business.question.entity.vo.PracticeVo;
import org.springframework.stereotype.Component;

import java.time.LocalDateTime;

/**
 * ExamUtil
 *
 * @author chenxueli
 * @date 2021/5/18 15:03
 */
@Component
public class ExamUtil {

    /**
     * 验证考试是否可以获取
     *
     * @param exam 考试信息
     */
    public void checkExamRun(ExamVo exam) {


    }

    /**
     * 验证考试是否可以继续生成试卷
     *
     * @param exam 考试信息
     */
    public void checkExamBuildPaper(ExamVo exam) {


    }

    /**
     * 验证练习的显示内容
     *
     * @param exam     考试信息
     * @param practice 练习数据
     */
    public void checkPracticeShow(ExamVo exam, PracticeVo practice) {
        // 判断考试是否结束
        if (exam.getViewAnswerType() == 1 && practice.getStatus() == Practice.Status.ANSWER) {
            return;
        }
        if (exam.getViewAnswerType() == 2 && LocalDateTime.now().isAfter(exam.getViewAnswerTime())) {
            return;
        }
        if (exam.getViewAnswerType() == 4 && LocalDateTime.now().isAfter(exam.getEndTime())) {
        }
    }


}
